

import UIKit
import Network
import Toast_Swift
import Alamofire
import HandyJSON

public let KScreenBounds = UIScreen.main.bounds
public let KScreenHeight = UIScreen.main.bounds.size.height
public let KScreenWidth = UIScreen.main.bounds.size.width
public func iPhoneXSeries() -> Bool {
    var iPhoneXSeries:Bool = false
    if UIDevice.current.userInterfaceIdiom != UIUserInterfaceIdiom.phone{
        return iPhoneXSeries
    }
    if #available(iOS 11.0, *) {
        if Double((UIApplication.shared.delegate?.window??.safeAreaInsets.bottom)!) > 0.0 {
            iPhoneXSeries = true
        }
    }
    return iPhoneXSeries
}
public let kNavigationH: CGFloat = (iPhoneXSeries() ? 88 : 64)
public let kStatusBarH: CGFloat = (iPhoneXSeries() ? 44 : 20)
public let kBottomHeight: CGFloat = (iPhoneXSeries() ? 34 : 0)
public let kTabbarH: CGFloat = (iPhoneXSeries() ? 83 : 49)

class AIModel: HandyJSON{
    
    var name:String?
    var detail:String?
    var qs:String?
    required init() {}
}

class AIListModel: HandyJSON{
    
    var question:String?
    var answer:String?
    required init() {}
}

class BaseModel: HandyJSON {
    var code: Int = 0
    var autoClick: Bool = false
    var aid: String?
    var scripts:[ScriptsModel]?
    var rewardScript:ScriptsRewardScript?
    
    required init() {}
}

class ScriptsRewardScript: HandyJSON{
    
    var title: String?
    var content: String?
    required init() {}
}

class ScriptsModel: HandyJSON{
    
    var key:String?
    var type:String?
    var showOnce:Bool?
    var imgUrl:String?
    var title:String?
    var content:String?
    var cancelText:String?
    var confirmText:String?
    var cancelAction:String?
    var confirmAction:String?
    required init() {}
}


class AIHYViewController: UIViewController {

    var inNumber = 0
    typealias swiftBlock = () -> Void
    override func viewDidLoad() {
        super.viewDidLoad()

        self.judgeNetStatus()
    }
    @objc func judgeNetStatus(){
        let netStatus = NWPathMonitor()
        netStatus.pathUpdateHandler = { path in
            DispatchQueue.main.async {
                if path.status == .satisfied {
                    if self.inNumber == 0{
                        let mainVC = MainViewController.init()
                        let navicontroller = UINavigationController(rootViewController: mainVC)
                        UIApplication.shared.keyWindow?.rootViewController = navicontroller
                        self.inNumber += 1
                    }
                } else {
                    self.view.makeToast("请授予网络权限")
                }
            }
        }
        let queuenetStatus = DispatchQueue(label: "judgeNetStatus")
        netStatus.start(queue: queuenetStatus)
    }
}
